package com.example.xhhweather;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.example.xhhweather.fragment.CityFragment;
import com.example.xhhweather.fragment.MyFragAdapter;

import java.util.ArrayList;
import java.util.List;

public class FragActivity extends AppCompatActivity {
    private ViewPager viewPager;
    private MyFragAdapter myFragAdapter;
    private List<Fragment> fragmentList=new ArrayList<>();
    private boolean isAddFragment=false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_frag);
        viewPager=findViewById(R.id.vp_frag);
        fragmentList.add(new CityFragment());
        fragmentList.add(new CityFragment());
        myFragAdapter=new MyFragAdapter(getSupportFragmentManager(),0,fragmentList);
        viewPager.setAdapter(myFragAdapter);

    }

}
